# Maintainer: Daniel M. Capella <polyzen@archlinux.org>

_name=lsprotocol
pkgname=python-lsprotocol
pkgver=2023.0.0a1
pkgrel=2
pkgdesc='Python implementation of the Language Server Protocol'
arch=('any')
url=https://github.com/microsoft/lsprotocol
license=('MIT')
depends=('python-cattrs')
makedepends=('git' 'python-build' 'python-flit-core' 'python-installer')
checkdepends=('python-jsonschema' 'python-pyhamcrest' 'python-pytest')
source=("git+$url.git?tag=$pkgver")
b2sums=('SKIP')

build() {
  cd $_name/packages/python
  python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd $_name
  pytest tests/python
}

package() {
  cd $_name/packages/python
  python -m installer --destdir="$pkgdir" dist/*.whl

  # Symlink license file
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  install -d "$pkgdir"/usr/share/licenses/$pkgname
  ln -s "$site_packages"/$_name-$pkgver.dist-info/LICENSE \
    "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
